package com.nacrtstudio.webgiftshop.pages.admin;

import org.apache.shiro.authz.annotation.RequiresRoles;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.ioc.annotations.Inject;

import com.nacrtstudio.webgiftshop.facade.Controller;
import com.nacrtstudio.webgiftshop.model.shop.Order;
import com.nacrtstudio.webgiftshop.subsystems.Mailing;

@RequiresRoles("admin")
public class EditOrder {
	@Inject
	private Controller controller;
	@Persist
	private Order order;
	
	public Order getOrder() {
		return order;
	}
	public void setOrder(Order order) {
		this.order = order;
	}
	
	@Inject
	private Mailing mailing;
	Object onSuccess(){
		controller.createOrder(order);
		mailing.sendMail("nacrtstudio@gmail.com", order.getUser().geteMail(), "Changed order status", "Your order status is - "+order.getOrderStatus());
		return OrderReports.class;
	}
}
